package com.forum.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.forum.model.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    @Select("SELECT * FROM category ORDER BY sort_order")
    List<Category> selectAll();

    @Select("SELECT * FROM category WHERE id = #{id}")
    Category selectById(Long id);

    @Update("UPDATE category SET post_count = post_count + 1 WHERE id = #{id}")
    int incrementPostCount(Long id);

    @Select("SELECT name FROM category WHERE id = #{id}")
    String selectNameById(Long id);
} 